#pragma once

#include "cocos2d.h"

namespace LTGame
{
	typedef enum _fileStorageFormat{
		BigEndian,
		LittleEndian,
	}fileStorageFormat;

	class  FileBin 
	{
	public:
		FileBin(const char *fileName, fileStorageFormat mode = BigEndian);
		~FileBin();

		unsigned long getFileSize() const { return peek_end; };
		void setCurPeek(unsigned long pos);

		unsigned char readByte( void );
		signed char readChar(void);
		short readShort( void );
		int readInt( void );
		char* readString( void );
		char* readUTF(void);
		int readData(char *data , int length);
		void skip(int position);

	protected:
		unsigned char* f;
		unsigned long peek_cur;
		unsigned long peek_end;
		fileStorageFormat m_mode;

	private:
		inline bool checkFileLenSafety(unsigned int size) const;
		cocos2d::CCFileData *m_fileData;
	};

}